<?php include $this->admin_tpl('meta', 'admin');?>
<title>员工列表</title>
</head>
<body>
<div class="page-container">
  <div> 
    <form action="<?php echo U('member_list');?>" method="get" id="search">
	 <input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
	 <input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
     <span class="select-box inline">
		<select name="department_id" class="select">
			<option value="">请选择部门</option>
			<?php echo $select_menus;?>
		</select>
	</span>
     <span class="select-box inline">
		<select name="status" class="select">
			<option value="">是否离职</option>
			<option value="1" <?php if(!isset($_GET['status']) || $_GET['status']=='1'){?> selected <?php }?>>在职</option>
			<option value="0" <?php if(isset($_GET['status']) && $_GET['status']=='0'){?> selected <?php }?>>离职</option>
		</select>
	</span>
    <span class="select-box inline">
		<select name="education" class="select">
			<option value="">选择学历</option>
			<option value="未知">未知</option>
			<option value="初中">初中</option>
			<option value="高中/中专">高中/中专</option>
			<option value="大专">大专</option>
			<option value="本科">本科</option>
			<option value="研究生">研究生</option>
		</select>
	</span>
     <span class="select-box inline">
		<select name="is_agree" class="select">
			<option value="">签订劳动合同</option>
			<option value="1" <?php if(isset($_GET['is_agree'])&&$is_agree==1){?> selected <?php }?>>已签</option>
			<option value="2" <?php if(isset($_GET['is_agree'])&&$is_agree==2){?> selected <?php }?>>未签</option>
		</select>
	</span>
     <input type="text" name="name" autocomplete="off" placeholder="请输入姓名" class="input-text" style="width:170px" value="<?php if(isset($_GET['name'])) echo $_GET['name'];?>">
	 <input type="text" name="mobile" autocomplete="off" placeholder="请输入手机号" class="input-text" style="width:170px" value="<?php if(isset($_GET['mobile'])) echo $_GET['mobile'];?>">
	 <input type="text" name="native_place" autocomplete="off" placeholder="籍贯" class="input-text" style="width:170px" value="<?php if(isset($_GET['native_place'])) echo $_GET['native_place'];?>">
	 <button name="dosubmit" class="btn btn-success radius" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
	 <a class="btn btn-primary radius" href="<?php echo U('member_list');?>"><i class="yzm-iconfont yzm-iconshuaxin"></i> 清空</a>
	 <button class="btn btn-warning radius" type="button" onclick="download('all')"><i class="yzm-iconfont yzm-iconxiazai"> 导出全部信息</i></button>
	 <button class="btn btn-warning radius" type="button" onclick="download('bank')"><i class="yzm-iconfont yzm-iconxiazai"> 导出银行信息</i></button>
	 <button class="btn btn-warning radius" type="button" onclick="download('last_bank')"><i class="yzm-iconfont yzm-iconxiazai"> 导出上月银行信息</i></button>
	 </form>	
  </div>
  <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
  <a href="javascript:;" onclick="yzm_open('添加用户','<?php echo U('member_add');?>','800','800')" class="btn btn-success radius"><i class="yzm-iconfont yzm-icontianjia"> 添加用户</i></a>
  <a href="javascript:;" onclick="yzm_dels('ids')" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"> 批量删除</i></a>
  </span> <span class="r">共有数据：<strong><?php echo $total?></strong> 条</span> </div>
  <form method="post" action="<?php echo U('member_delete');?>" id="myform">
  <table class="table table-border table-bordered table-bg table-hover yzm-table-sort">
    <thead>
      <tr class="text-c">
        <th width="25"><input type="checkbox"></th>
		<th width="35">ID<?php echo field_order('m.id');?></th>
		<th width="80">姓名</th>
		<th width="110">电话</th>
		<th class="text-l">部门<?php echo field_order('m.department_id');?></th>
		<th width="50">岗位</th>
		<th width="45">工龄<?php echo field_order('m.in_time');?></th>
		<th width="130" class="text-l">年假</th>
		<th width="93">薪资<?php echo field_order('ml.money');?></th>
		<th width="75">房补</th>
		<th width="40">餐补</th>
		<th width="55">社保</th>
		<th width="80">入职/离职时间</th>
		<th width="50">是否在职</th>
		<th width="90">银行信息</th>
		<th width="80">籍贯</th>
		<th width="65">合同编号</th>
		<th width="120">操作</th>
      </tr>
    </thead>
    <tbody>
		<?php 
		foreach($data as $val){
		?>
		  <tr class="text-c">
			<td><input type="checkbox" value="<?php echo $val['id']?>" name="ids[]"></td>
			<td><?php echo $val['id']?></td>
			<td><span class="f-l"><img src="<?php echo $val['img'];?>" height="30"></span> <span class="f-l ml-10" style="margin-top:3px;"><?php echo $val['name'];?></span></a></td>
			<td>
				<span class="f-l"><?php echo $val['mobile'];?></span>
				<span class="f-r">
				<a href="tel:<?php echo $val['mobile'];?>" class="btn btn-success radius" style="height:25px;width:25px;border-radius:50%;text-align:center;font-size:16px;line-height:22px;padding:0;"><i class="yzm-iconfont yzm-icondianhua"></i></a>
				</span>
			</td>
			<td class="text-l"><?php echo department($val['department_id']);?></td>
			<td><?php echo $val['position_name'];?></td>
			<td><?php if($val['status']){echo $val['years'].'年';}else{ echo '离职';}?></td>
			<td class="text-l">
				<?php if($val['status']){?>
				<span class="f-l">
				<?php if($val['position_leave_days']<1){?>
				无年假
				<?php }elseif($val['years']>=1){?>
				剩<?php echo $val['leave_days'];?>天(<?php echo date('y-m-d',$val['leave_expire'])?>)
				<?php }else{ ?>
				<?php echo $val['leave_days'];?>天(工龄不够)
				<?php }?>
				</span>
				<?php if($val['position_leave_days']&&$val['years']>=1&&$val['leave_days']>0){?>
				<a href="javascript:;" style="margin-left:3px;height:22px;width:26px;text-align:center;font-size:14px;line-height:20px;padding:0;" onclick="yzm_open('新增休假明细','<?php echo U('hr_leave/leave_add',['member_id'=>$val['id']]);?>','800','500')" class="btn btn-success radius"><i class="yzm-iconfont yzm-icontianjia"></i></a>
				<?php } ?>
				<?php }else{ echo '离职'; }?>
			</td>
			<td>
				<span class="f-l">****</span>
				<span class="f-l" style="display:none;"><?php echo $val['money'];?></span>
				<span class="f-l" onclick="look(this);">
					<a href="javascript:;" class="btn btn-default radius" style="margin-left:3px;height:22px;width:26px;text-align:center;font-size:18px;line-height:18px;padding:0;">
						<i class="yzm-iconfont yzm-iconpreview"></i>
					</a>
				</span>
				<span class="f-l">
				
				<?php if(!$val['money_wait_action']){?>
				<a href="javascript:;" style="margin-left:3px;height:22px;width:26px;text-align:center;font-size:14px;line-height:20px;padding:0;" onclick="yzm_open('新增薪资变动','<?php echo U('hr_money/money_add',['member_id'=>$val['id']]);?>','800','500')" class="btn btn-success radius">
				<i class="yzm-iconfont yzm-icontianjia"></i></a>
				<?php }else{ ?>
				<a href="javascript:;" style="margin-left:3px;height:22px;width:26px;text-align:center;font-size:14px;line-height:20px;padding:0;" onclick="yzm_open('新增薪资变动','<?php echo U('hr_money/money_add',['member_id'=>$val['id']]);?>','800','500')" class="btn btn-warning radius">
				<i class="yzm-iconfont yzm-icontianjia"></i></a>
				<?php } ?>
				</span>
			</td>
			<td>
				<span class="f-l">****</span>
				<span class="f-l" style="display:none;"><?php echo $val['housing_money'];?></span>
				<span class="f-r" onclick="look(this);">
					<a href="javascript:;" class="btn btn-default radius" style="margin-left:3px;height:22px;width:26px;text-align:center;font-size:18px;line-height:18px;padding:0;">
						<i class="yzm-iconfont yzm-iconpreview"></i>
					</a>
				</span>
			</td>
			<td>
				<?php echo $val['meal_money'] ? $val['meal_money'] : '-';?>
			</td>
			<td>
				<?php if($val['is_ss']){ ?>
				<span class="yzm-status-enable"><i class="yzm-iconfont">&#xe81f;</i>已购买</span>
				<?php }else{ ?>
				<span class="yzm-status-disable"><i class="yzm-iconfont">&#xe601;</i>未购买</span>
				<?php } ?>
			</td>
			<td><?php echo date('Y-m-d',$val['in_time']);?><br/><?php echo $val['out_time']?date('Y-m-d',$val['out_time']):'';?></td>
			<td>
				<?php if($val['status']){ ?>
				<span class="yzm-status-enable" data-field="status" data-id="<?php echo $val['id']?>"><i class="yzm-iconfont">&#xe81f;</i>是</span>
				<?php }else{ ?>
				<span class="yzm-status-disable" data-field="status" data-id="<?php echo $val['id']?>"><i class="yzm-iconfont">&#xe601;</i>否</span>
				<?php } ?>
			</td>
			<td>
				<span class="f-l"><?php echo cut_str($val['bank_name'],4);?></span>
				<span class="f-r">
				<a onclick="open_bank(this)" data="<?php echo '员工姓名：'.$val['name'].'<br>银行名称：'.$val['bank_name'].'<br>银行卡号：'.$val['bank_code'].'<br>银行户名：'.$val['bank_account']?>" class="btn btn-success radius" style="height:25px;width:25px;border-radius:50%;text-align:center;font-size:14px;line-height:22px;padding:0;"><i class="yzm-iconfont yzm-iconzhifu"></i></a>
				</span>
			</td>
			<td><?php echo cut_str($val['native_place'],5);?></td>
			<td><?php echo $val['agree_no'];?></td>
			<td>
				<a title="查看员工信息" href="javascript:;" member_id="<?php echo $val['id'];?>" style="text-decoration:none" class="btn-mini btn-success btn_member_info">查看</a>
				<a title="编辑员工信息" href="javascript:;" onclick="yzm_open('编辑员工信息','<?php echo U('member_add',array('id'=>$val['id']));?>',800,800)" style="text-decoration:none" class="btn-mini btn-primary ml-5">编辑</a>
			</td>
		  </tr>		
		<?php 
		}
		?>
    </tbody>
  </table>
  <?php if(!$data){ ?><div class="yzm_no_data"><i class="Hui-iconfont">&#xe6e0;</i> 暂无数据</div><?php } ?>
  </form>
  <div id="page"><span class="page_left">共<?php echo $total?>条记录，共<?php echo $page->total()?>页，当前显示第<?php echo $page->getpage()?>页</span>
  <span class="page_right"><?php echo $page->getfull();?></span></div>
</div>
<?php include $this->admin_tpl('footer', 'admin');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script type="text/javascript">

$('.btn_member_info').on('click',function(){
	let member_id = $(this).attr('member_id');
	let url = '<?php echo U('member_info')?>'+'?id='+member_id;
	let width = '800px';
	if(screen.width<800){
		width = '100%';
	}
	layer.open({  
		type: 2,  
		title: '查看员工信息',  
		shadeClose: true,  
		shade: 0.2,  
		area: [width, '700px'],  
		content: url,
		success: function(layero, index){
			
		}
	})
	return false;
})
function open_bank(obj){
	layer.open({
	  title: '查看银行卡信息',
	  content: $(obj).attr('data')
	});     
}

	function look(obj){
		if($(obj).find('a').eq(0).hasClass('btn-default')){
			$(obj).find('a').removeClass('btn-default');
			$(obj).find('a').addClass('btn-success');
			$(obj).prev().show();
			$(obj).prev().prev().hide();
		}else{
			$(obj).find('a').addClass('btn-default');
			$(obj).find('a').removeClass('btn-success');
			$(obj).prev().prev().show();
			$(obj).prev().hide();
		}
	}

	function lock(){
		if ($("input[name='ids[]']:checked").length<1){
		   layer.alert('请勾选信息！');
		   return false;
		}	
		document.getElementById('myform').action='<?php echo U('lock')?>';
		document.getElementById('myform').submit();
	}

	function unlock(){
		if ($("input[name='ids[]']:checked").length<1){
		   layer.alert('请勾选信息！');
		   return false;
		}	
		document.getElementById('myform').action='<?php echo U('unlock')?>';
		document.getElementById('myform').submit();
	}


	var start = {elem:'#start',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD hh:mm:ss',min:'1999-01-01',max:'2099-01-01',istime:true,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);
	
//点击导出新窗口打开
function openNewWindow(url) {
    var a = document.createElement('a');
    a.setAttribute('href', url);
    a.setAttribute('target', '_blank');
    var id = Math.random(10000, 99999);
    a.setAttribute('id', id);
    // 防止反复添加
    if (!document.getElementById(id)) {
        document.body.appendChild(a);
    }
    a.click();
}

function download(type){
	var t = $('form').serializeArray();
	var d = '<?php echo U('download');?>?type='+type;
	openNewWindow(d);
}
</script>

</body>
</html>